package com.chanyachting.emall.action.companyproduct;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Match;
import com.chanyachting.emall.form.MatchForm;
import com.chanyachting.emall.service.CompanyproductService;
import com.chanyachting.emall.service.MatchService;
import com.chanyachting.emall.serviceImpl.CompanyproductServiceImpl;
import com.chanyachting.emall.serviceImpl.MatchServiceImpl;
import com.chanyachting.emall.util.DateUtil;

public class UpdateMatchAction extends Action {
	
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		MatchForm maform=(MatchForm)form;
		
		try {
			MatchService matchService=new MatchServiceImpl();
			
			Match tmpMa = matchService.getOneMatchById(maform.getId().toString());
			Match ma=new Match();
			
			BeanUtils.copyProperties(ma,maform);
			
			ma.setUpdateDate(DateUtil.getDate()); 
			ma.setCreateDate(tmpMa.getCreateDate());
			ma.setTitle(ma.getName());
			ma.setStatus("00");
			
			CompanyproductService cpservice=new CompanyproductServiceImpl();
			
			cpservice.updateCompanyproduct(ma);
			
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		
		
		return mapping.findForward("updateMatch");
	}
	

}
